import React, { Component } from 'react';
import { connect } from 'dva';
import PropTypes from 'prop-types';
import { Spin, Icon } from 'antd';
import styles from './echartStyle.less';

class LineBarChart extends Component {
  static propTypes = {
    // secu_code: PropTypes.string.isRequired,
    // type: PropTypes.string,
    chartID: PropTypes.string,
  };

  static defaultProps = {
    chartID: '',
  };

  componentDidMount() {
    // console.log("To",sessionStorage.getItem('LOGIN_INFO'))
    const { dispatch, chartID } = this.props;

    dispatch({
      type: 'home/getHlbt',
      chartID: chartID,
      payload: {
        stock_code: JSON.parse(sessionStorage.getItem('LOGIN_INFO')).stock_code,
      },
    });
  }

  render() {
    const { chartID, data, loading } = this.props;
    // console.log("data",data)

    return (
      <div>
        <div className="titleLine">
          <div style={{ float: 'left', display: 'inline-flex' }}>
            <div className="kk" />
            <span>
              {JSON.parse(sessionStorage.getItem('LOGIN_INFO')).market === 90 && '互动易'}
              {JSON.parse(sessionStorage.getItem('LOGIN_INFO')).market === 83 && 'E互动'}
            </span>
          </div>
          <div style={{ float: 'right', fontSize: '14px', color: '#999', marginRight: '20px' }}>
            最近一年新增提问 <span style={{ color: '#d8a874' }}>{data.total_count}</span> 条，有{' '}
            <span style={{ color: '#d8a874' }}>{data.no_reply_count}</span> 条尚未回复
          </div>
        </div>
        <div className={styles.homeTopScendFlexBox}>
          <Spin tip="数据读取中..." spinning={loading}>
            <div id={chartID} className={styles.lineContainer} />
          </Spin>
        </div>
      </div>
    );
  }
}

const mapStateToProps = state => ({
  loading: state.loading.effects['home/getHlbt'],
  data: state.home.lineBar === null ? [] : state.home.lineBar,
});
// ,console.log("LineBarChart-state",state.loading.effects['home/getHlbt'])

// ({
//   messager:state.home.doubleLine.messager
// })
// { console.log("LineBarChart-state",state.home.doubleLine) }

export default connect(mapStateToProps)(LineBarChart);
